﻿@model BlogModels.Blog

@{
    ViewBag.Title = "Edit";
    Layout = "~/Views/Shared/_LayoutMain.cshtml";
}

@Styles.Render("~/Content/admin/css/maininfo")


@using (Html.BeginForm())
{
    @Html.AntiForgeryToken()

      <!--main_top-->
    <table width="99%" border="0" cellspacing="0" cellpadding="0" id="searchmain">
        <tr>
            <td width="99%" align="left" valign="top">您的位置：博客管理&nbsp;&nbsp;>&nbsp;&nbsp;添加博客</td>
        </tr>
        <tr>
            <td align="left" valign="top" id="addinfo">
                <a href="add.html" target="mainFrame" onFocus="this.blur()" class="add">新增博客</a>
                @Html.ActionLink("返回博客列表", "Index")
            </td>
        </tr>
        <tr>
            <td>
                <table width="100%" border="0" cellspacing="0" cellpadding="0" id="main-tab">
                    <tr onMouseOut="this.style.backgroundColor='#ffffff'" onMouseOver="this.style.backgroundColor='#edf5ff'">
                        <td align="right" valign="middle" class="borderright borderbottom bggray">博客标题：</td>
                        <td align="left" valign="middle" class="borderright borderbottom main-for">
                            @Html.EditorFor(model => model.Title, new { htmlAttributes = new { @class = "text-word" } })
                            @Html.ValidationMessageFor(model => model.Title, "", new { @class = "text-danger" })
                        </td>
                    </tr>
                    <tr onMouseOut="this.style.backgroundColor='#ffffff'" onMouseOver="this.style.backgroundColor='#edf5ff'">
                        <td align="right" valign="middle" class="borderright borderbottom bggray">图片标题：</td>
                        <td align="left" valign="middle" class="borderright borderbottom main-for">
                           @Html.EditorFor(model => model.PicTitle, new { htmlAttributes = new { @class = "text-word" } })
                        
                            <span class="input-group-btn">
                                <button type="button" id="j_upload_img_btn" class="text-but">上传图片</button>
                            </span>
                            @Html.ValidationMessageFor(model => model.PicTitle, "", new { @class = "text-danger" })
                        </td>
                    </tr>
                    <tr onMouseOut="this.style.backgroundColor='#ffffff'" onMouseOver="this.style.backgroundColor='#edf5ff'">
                        <td align="right" valign="middle" class="borderright borderbottom bggray">博客内容：</td>
                        <td align="left" valign="middle" class="borderright borderbottom main-for">
                            @Html.TextAreaFor(model => model.Content)
                            @Html.ValidationMessageFor(model => model.Content, "", new { @class = "text-danger" })
                            @Html.ValidationSummary(true, "", new { @class = "text-danger" })
                            @Html.HiddenFor(model => model.Id)
                            @Html.HiddenFor(model => model.AddTime)
                            @Html.HiddenFor(model => model.EditTime)
                        </td>
                    </tr>

                    <tr onMouseOut="this.style.backgroundColor='#ffffff'" onMouseOver="this.style.backgroundColor='#edf5ff'">
                        <td align="right" valign="middle" class="borderright borderbottom bggray">&nbsp;</td>
                        <td align="left" valign="middle" class="borderright borderbottom main-for">
                            <input name="" type="submit" value="提交" class="text-but">
                            <input name="" type="reset" value="重置" class="text-but">
                        </td>
                    </tr>
                </table>
            </td>
        </tr>
    </table>
    <textarea id="uploadEditor" style="display: none;"></textarea>
      
}



@section Scripts {
    @Scripts.Render("~/bundles/jqueryval")
    @Scripts.Render("~/UEditor/Config")
    <script>
        //创建UEditor编辑器
        var editor = UE.getEditor("Content", {
            UEDITOR_HOME_URL: '/ueditor/',
            iframeCssUrl: '/ueditor/themes/iframe.css',
            autoHeightEnabled: true,
            initialFrameHeight: 400,
            initialFrameWidth: 1000
        });

        var uploadEditor = UE.getEditor("uploadEditor", {
            isShow: false,
            focus: false,
            enableAutoSave: false,
            autoSyncData: false,
            autoFloatEnabled: false,
            wordCount: false,
            sourceEditor: null,
            scaleEnabled: true,
            toolbars: [["insertimage"]]
        });
        document.getElementById('j_upload_img_btn').onclick = function () {
            var dialog = uploadEditor.getDialog("insertimage");
            dialog.title = '上传图片';
            dialog.render();
            dialog.open();
        };

        // 监听多图上传和上传附件组件的插入动作
        uploadEditor.ready(function () {
            uploadEditor.addListener("beforeInsertImage", _beforeInsertImage);
        });

        // 多图上传动作
        function _beforeInsertImage(t, result) {
            var imageHtml = result[0].src;
            //for (var i in result) {
            //    imageHtml += '<li><img src="' + result[i].src + '" alt="' + result[i].alt + '" height="150"></li>';
            //}
            document.getElementById('PicTitle').value = imageHtml;
        }
    </script>
}
